package com.offcn.login;

import com.offcn.dao.StudentDao;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

//删除操作的servlet
@WebServlet("/delete")
public class deleteServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获取要删除学生的id
        int id = Integer.parseInt(req.getParameter("id"));
        //实例化StudentDao
        StudentDao sd = new StudentDao();
        //调用删除学生信息方法
        boolean b = sd.delete(id);
        //删除之后跳转回主页面
        resp.sendRedirect("student");
    }
}
